package www.reagnetbox.com.view;

import android.content.Context;

import com.lxj.xpopup.core.CenterPopupView;
import com.lxj.xpopup.util.XPopupUtils;

import www.reagnetbox.com.R;
import www.reagnetbox.com.callback.IntegerCallback;
import www.reagnetbox.com.others.SerialPortConst;

public class SelOutPortPopup extends CenterPopupView {
    Context context;
    IntegerCallback callback;

    public SelOutPortPopup(Context context, IntegerCallback callback) {
        super(context);
        this.callback = callback;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.popup_sel_out_port;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        findViewById(R.id.tv_left_port).setOnClickListener(v -> {
            dismiss();
            callback.fun(SerialPortConst.PORT_OUT_LEFT);
        });
        findViewById(R.id.tv_right_port).setOnClickListener(v -> {
            dismiss();
            callback.fun(SerialPortConst.PORT_OUT_RIGHT);
        });
    }

    @Override
    protected int getMaxWidth() {
        return (int) (XPopupUtils.getScreenWidth(getContext()) * .35f);
    }

    @Override
    protected int getMaxHeight() {
        return (int) (XPopupUtils.getScreenHeight(getContext()) * .35f);
    }
}
